import request from '@/utils/request'

interface LoginParams {
  email: string
  password: string
  captchaCode: string
  captchaKey: string
  rememberMe: boolean
}

export interface RegisterParams {
  username: string
  password: string
  confirmPassword: string
  nickname?: string
  mobile?: string
  email: string
  verifyCode: string
  captchaCode: string
  captchaKey: string
  invitedBy?: string
  socialMedia?: Record<string, string>
}

// 登录接口
export function loginApi(data: LoginParams) {
  return request({
    url: '/auth/login',
    method: 'post',
    data
  })
}

// 注册接口
export function registerApi(data: RegisterParams) {
  return request({
    //  url: '/auth/register',
    url: '/api/email/register',
    method: 'post',
    data
  })
}

// 获取验证码
export function getCaptchaApi() {
  return request({
    // url: '/sys/config/getConfigByKey/slider_verify_switch',
    url: '/auth/getCaptcha',
    // url: '/auth/captcha',
    method: 'get'
  })
}


// 获取验证码开关
export function getCaptchaSwitchApi() {
  return request({
     url: '/sys/config/getConfigByKey/slider_verify_switch',
    // url: '/auth/captchaSwitch',
    method: 'get'
  })
}

// 获取用户信息
export function getUserInfoApi() {
  return request({
    url: '/auth/info',
    method: 'get'
  })
}

// 退出登录
export function logoutApi() {
  return request({
    url: '/auth/logout',
    method: 'post'
  })
}

export function getRouters() {
  return request({
    url: '/sys/menu/routers',
    method: 'get'
  })
}

// 发送验证码接口
export function sendVerifyCodeApi(email: string) {
  return request({
    url: '/api/sendEmailCode',
    method: 'get',
    params: { email }
  })
}